package cn.doitedu.groovy_test;

import groovy.lang.GroovyClassLoader;

public class FlinkMain {

    public static void main(String[] args) throws InstantiationException, IllegalAccessException {

        String code = "package cn.doitedu.groovy_test\n" +
                "\n" +
                "class CalculatorModel implements  MyCalculator{\n" +
                "    @Override\n" +
                "    void init(String name) {\n" +
                "\n" +
                "        System.out.println(\"我被初始化了: \" + name)\n" +
                "    }\n" +
                "\n" +
                "    @Override\n" +
                "    void calc(String name) {\n" +
                "        System.out.println(\"我被calc了: \" + name)\n" +
                "    }\n" +
                "}\n";

        GroovyClassLoader groovyClassLoader = new GroovyClassLoader();
        Class aClass = groovyClassLoader.parseClass(code);

        MyCalculator calculator = (MyCalculator) aClass.newInstance();

        calculator.init("haha");
        calculator.calc("heihei");



    }

}
